#include <pc.h>
#include "utypes.h"
#include "timer.h"

extern int time_tick;
extern int sec_tick;
void timer_init(int timer, int mode)
{
	//outportb(TIMER_CTRL, ( timer << 6 ) | mode);
	if (timer == TIMER_2) {
		unsigned char a=inportb(SPEAKER_CTRL);	
		outportb(SPEAKER_CTRL, a | TIMER2_ENABLE | mode );
	}
}

void timer_load(int timer, int value)
{
	outportb(timer, LSB(value) ); //menos significativos
	outportb(timer, MSB(value) ); //mais significativos
}


void mili_sleep(int mili)
{
	time_tick=0;
	while( time_tick < mili )
	{}
}

void sec_sleep(int secs)
{
	sec_tick=0;
	while( sec_tick < secs )
	{}
}